/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.servlet;

import com.qdu.entity.Movie;
import com.qdu.service.impl.MovieServiceImpl;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Lenovo
 */
@WebServlet("/smbss")
public class SearchMovBokServlet extends HttpServlet{
    
    MovieServiceImpl movieServiceImpl = new MovieServiceImpl();
    //BookService movieService = new BookService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         //1. 获取请求参数
        //获取提交的电影名称关键字
        String keyword = req.getParameter("keyword");
        
        //2. 执行业务逻辑 
        //调用MovieServiceImpl类的findMoviesByKeyword()方法根据关键字查询电影列表
        //但是并没有查询电影的所有信息，只是查询了基本信息
              List<Movie> list1 = movieServiceImpl.findMoviesByKeyword(keyword);
             // List<Book>  list2 = bookServiceImpl.findBooksByKeyword(keyword);

        //3. 生成动态响应
        //将查到的电影列表作为属性放入请求对象，movie_list.jsp页面显示电影信息
             req.setAttribute("searchList", list1);
             //req.setAttribute("searchList", list2);
        req.getRequestDispatcher("/searchList.jsp").forward(req, resp);
    }

}
